<?php

namespace yak\layui\widgets\grid;

use yii\grid\Column;
use yii\helpers\ArrayHelper;

/**
 * Class LayuiActionColumn
 * @package yak\layui\widgets
 */
class LayuiActionColumn extends Column implements LayuiColInterface
{
    /**
     * @var string
     */
    public $header = '操作';

    /**
     * @var string
     */
    public $toolbar = '';

    public $defaultColOptions = [
        'fixed' => 'right'
    ];

    public function renderDataCell($model, $key, $index)
    {
        return ""; // TODO: Change the autogenerated stub
    }

    public function generateCol(): array
    {
        // TODO: Implement generateCol() method.
        $colOptions = ArrayHelper::getValue($this->options,
            'colOptions', $this->defaultColOptions);
        $colOptions['toolbar'] = $this->toolbar;
        $colOptions['title'] = $this->header;
        return $colOptions;
    }

    public function getLabel(): string
    {
        // TODO: Implement getLabel() method.
        return $this->header;
    }
}
